#include <iostream>

void swapr(int & a, int & b);

int main(int argc, const char * argv[])
{
	using namespace std;
	long a = 1, b = 2;
	cout << "before swap: a = " << a << " b = " << b << endl;
	swapr(a, b); //.\ref_test.cpp:10:8: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int' 
	// 编译器禁止为我们创建临时变量并与引用变量绑定(因为使用引用参数的函数意图修改所引用的变量，因此编译器禁止创建临时变量，这个做法是合理的)
	cout << "after swap: a = " << a << " b = " << b << endl;
	return 0;
}

void swapr(int & a, int & b)
{
	int temp = 0;
	temp = a;
	a = b;
	b = temp;
}